package com.sunrise.generico.entidade;

import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.validator.constraints.NotEmpty;

import com.sunrise.generico.entidade.iface.EntidadeManter;

@Entity
@Table(name = "conta_sms")
public class ContaSms implements EntidadeManter {

	private static final long serialVersionUID = -3070159621011097321L;

	@Id
	@SequenceGenerator(name="pk_sequence",sequenceName="conta_sms_id_seq", allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="pk_sequence")
	@javax.persistence.Column
	@Getter @Setter
	private Long id;
	
	@NotEmpty( message="{contaSmsObrigatorio}")
	@Column(name = "nome", length = 60, nullable = false, unique = true)
	@Getter @Setter
	private String nome;
	
	@Column(name = "username", length = 20, nullable = false, unique = true)
	@Getter @Setter
	private String username;
	
	@Column(name = "password", length = 60)
	@Getter @Setter
	private String password;
	
	@Column(name = "credito")
	@Getter @Setter
	private Integer credito;
	
	@OneToOne
	@Getter @Setter
	private Usuario criador;
	
	
	@Column(name = "enviarAniversario")
	@Getter @Setter
	private Boolean enviarAniversario;
	
	
	@ManyToMany(fetch=FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE })
	@JoinTable(name="contasms_usuario", joinColumns={@JoinColumn(name="contasms_id", referencedColumnName="id")},
		      inverseJoinColumns={@JoinColumn(name="usuario_id", referencedColumnName="id")})
	@Getter @Setter
	private Collection<Usuario> usuarios;
	
	@Column(name = "ativo")
	@Getter @Setter
	private Boolean ativo;
	
	@Column(name = "enviarSmsAniversario")
	@Getter @Setter
	private Boolean enviarSmsAniversario;
	
	@Column(name = "mensagemAniversario", length = 150)
	@Getter @Setter
	private String mensagemAniversario;
	
	@OneToMany
	@Getter @Setter
	private Collection<ComunicacaoSMS> comunicacoes;
	
	
	
}
